﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Dotnet.Code.Extend
{
    public static partial class Ext
    {
        public static void WriteLine(this Thread t, string remark, params Thread[] threads)
        {
            DateTime dt = DateTime.Now;
            System.Diagnostics.StackFrame stf = new System.Diagnostics.StackTrace(true).GetFrame(1);
            StringBuilder sb = new StringBuilder();
            foreach (Thread item in threads)
            {
                sb.AppendFormat("[线程名:{0,-5} ID:{1} 状态:{2,-13} 优先级:{3}] ", item.Name, item.ManagedThreadId, item.ThreadState, item.Priority);
            }
            Console.WriteLine("{0:HH:mm:ss.fff} L:{1,-4}{2,-12}\t当前线程名:{3,-5} ID:{4} 状态:{5,-13} 优先级:{6}\t{7} ",
                dt, stf.GetFileLineNumber(), remark, t.Name, t.ManagedThreadId, t.ThreadState, t.Priority, sb.ToString());
        }
    }
}
